<input type="text" name="{{$findgrid_address_list_name or 'findgrid_address_list_name'}}"
       value="{{$findgrid_address_list_name_value or ''}}"
       data-toggle="findgrid" data-options="{
                        checkEnable: true,
                        chkStyle: 'checkbox',
                        empty: true,
                        beforeSelect: isEmployee,
                        multiple: {{$multiple or 'false'}},
                        include: '{{$findgrid_contacts_id or 'oa_contacts_id'}}:id,{{$findgrid_address_list_name or 'findgrid_address_list_name'}}:name,{{$findgrid_department_id or 'oa_department_id'}}:department_id',
                        dialogOptions: {
                                id: 'find-address-list',
                                title:'查询通讯录数据（仅可选择员工）',
                                width: 800,
                                height:700
                        },
                        gridOptions: {
                                local: 'local',
                                dataUrl: '/admin/personnel/address-list-employee',
                                paging: false,
                                linenumberAll: true,
                                fieldSortable: false,
                                columns: [
                                    {name:'name', label:'名称', align:'center', width:200},
                                    {name:'position', label:'职位', align:'center', width:200},
                                    {name:'mobile', label:'手机号码', align:'center', width:200},
                                ],
                                isTree:'name',
                                treeOptions:{
                                    keys: {
                                        key: 'department_id',        // id
                                        parentKey: 'oa_department_id',       // 父id
                                        childKey: 'contacts_list',  // 子列表数据key值
                                        isExpand: {{$isExpand or 'false'}},   // 子列表是否展开
                                    },
                                expandAll: false,
                                simpleData: true,          // 是否简单数据(array格式)
                                add: false           // 显示添加按钮
                                }
                        },
                        {{--onSelect:{{$findgrid_address_list_name or 'assemblingAddressListString'}},--}}
        }" data-rule="{{$data_rule or 'required'}}" placeholder="点放大镜按钮查找" readonly>
<input type="hidden" name="{{$findgrid_contacts_id or 'oa_contacts_id'}}" value="{{$findgrid_contacts_id_value or ''}}">
<input type="hidden" name="{{$findgrid_department_id or 'oa_department_id'}}"
       value="{{$findgrid_department_id_value or ''}}">
<script>
    {{--function {{$findgrid_address_list_name or 'assemblingAddressListString'}}(data) {--}}
    {{--var contacts_string = '';--}}
    {{--var department_string = '';--}}
    {{--var name_string = '';--}}
    {{--if (data instanceof Array) {--}}
    {{--for(var i=0;i<data.length;i++){--}}
    {{--if(data[i].department_id){--}}
    {{--department_string += ',' + data[i].department_id;--}}
    {{--name_string += ',' + data[i].name;--}}
    {{--} else if (data[i].employee_id) {--}}
    {{--contacts_string += ',' + data[i].employee_id;--}}
    {{--name_string += ',' + data[i].name;--}}
    {{--}--}}
    {{--}--}}
    {{--} else {--}}
    {{--if(data.department_id){--}}
    {{--department_string = ',' + data.department_id;--}}
    {{--name_string = ',' + data.name;--}}
    {{--} else if(data.employee_id) {--}}
    {{--contacts_string = ',' + data.employee_id;--}}
    {{--name_string = ',' + data.name;--}}
    {{--}--}}
    {{--}--}}
    {{--contacts_string = contacts_string.substring(1);--}}
    {{--department_string = department_string.substring(1);--}}
    {{--name_string = name_string.substring(1);--}}
    {{--$("input[name='{{$findgrid_contacts_id or 'oa_contacts_id'}}']").val(contacts_string);--}}
    {{--$("input[name='{{$findgrid_department_id or 'oa_department_id'}}']").val(department_string);--}}
    {{--$("input[name='{{$findgrid_address_list_name or 'findgrid_address_list_name'}}']").val(name_string);--}}
    {{--BJUI.dialog('closeCurrent');--}}
    {{--}--}}
    function isEmployee(data) {
        var k = 1;
                @if (isset($multiple))
        for (var i = 0; i < data.length; i++) {
            if (!data[i].id) {
                k = 0;
            }
        }
        @else
        if (!data.id) k = 0;
        @endif
        if (k) {
            return true;
        } else {
            return false;
        }
    }
</script>
<style>
    .ilabel {
        display: none;
    }
</style>